package com.th.supcom.pds.impl.service.internal.phamapply;

import java.util.List;

import net.carefx.framework.exception.BusinessException;
import net.carefx.framework.translate.TranslatorManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.th.supcom.pds.domain.pojo.InpPhamDispenseDetail;
import com.th.supcom.pds.impl.common.PdsConstants;
import com.th.supcom.pds.impl.manager.InpPhamDispenseDetailManager;
import com.th.supcom.pds.internal.api.phamapply.InpPhamDispenseDetailBasicService;

public class InpPhamDispenseDetailBasicServiceImpl implements InpPhamDispenseDetailBasicService
{
    /** 日志记录器. */
    public static final Logger s_logger = LoggerFactory.getLogger (InpPhamDispenseDetailBasicServiceImpl.class);
    private InpPhamDispenseDetailManager m_inpPhamDispenseDetailManager;
    private TranslatorManager m_translatorManager;

    public void setTranslatorManager (TranslatorManager translatorManager)
    {
        m_translatorManager = translatorManager;
    }

    public void setInpPhamDispenseDetailManager (InpPhamDispenseDetailManager inpPhamDispenseDetailManager)
    {
        m_inpPhamDispenseDetailManager = inpPhamDispenseDetailManager;
    }

    @Override
    public InpPhamDispenseDetail getInpPhamDispenseDetailByID (Long id)
    {
        s_logger.info ("调用getInpPhamDispenseDetailByID参数 ：id:{}", new Object[]
        { id });
        if (null == id)
        {
            s_logger.error ("通过主键查询摆药记录表时，主键不能为空");
            throw new IllegalArgumentException ("通过主键查询摆药记录表时，主键不能为空");
        }
        try
        {
            InpPhamDispenseDetail inpPhamDispenseDetail = m_inpPhamDispenseDetailManager.getInpPhamDispenseDetailByID (id);
            inpPhamDispenseDetail = m_translatorManager.translate (inpPhamDispenseDetail);
            return inpPhamDispenseDetail;
        }
        catch (Exception e)
        {
            s_logger.error ("通过主键查询摆药记录表异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过主键查询摆药记录表异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public List <InpPhamDispenseDetail> findInpPhamDispenseDetailListByExample (InpPhamDispenseDetail inpPhamDispenseDetail)
    {
        s_logger.info ("调用findInpPhamDispenseDetailListByExample参数 ：inpPhamDispenseDetail:{}", new Object[]
        { inpPhamDispenseDetail });
        if (inpPhamDispenseDetail == null)
        {
            s_logger.error ("通过条件查询摆药记录表时，条件对象不能为空");
            throw new IllegalArgumentException ("通过条件查询摆药记录表时，条件对象不能为空");
        }
        try
        {
            List <InpPhamDispenseDetail> list = m_inpPhamDispenseDetailManager.findInpPhamDispenseDetailListByExample (inpPhamDispenseDetail);
            list = m_translatorManager.translate (list);
            return list;
        }
        catch (Exception e)
        {
            s_logger.error ("通过条件查询摆药记录表异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过条件查询摆药记录表异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public int findInpPhamDispenseDetailCountByExample (InpPhamDispenseDetail inpPhamDispenseDetail)
    {
        s_logger.info ("调用findInpPhamDispenseDetailCountByExample参数 ：inpPhamDispenseDetail:{}", new Object[]
        { inpPhamDispenseDetail });
        if (inpPhamDispenseDetail == null)
        {
            s_logger.error ("通过条件查询摆药记录表记录数时，条件对象不能为空");
            throw new IllegalArgumentException ("通过条件查询摆药记录表记录数时，条件对象不能为空");
        }
        try
        {
            return m_inpPhamDispenseDetailManager.findInpPhamDispenseDetailCountByExample (inpPhamDispenseDetail);
        }
        catch (Exception e)
        {
            s_logger.error ("通过条件查询摆药记录表记录数异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过条件查询摆药记录表记录数异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public int modifyInpPhamDispenseDetail (InpPhamDispenseDetail inpPhamDispenseDetail)
    {
        s_logger.info ("调用modifyInpPhamDispenseDetail参数 ：inpPhamDispenseDetail:{}", new Object[]
        { inpPhamDispenseDetail });
        if (inpPhamDispenseDetail == null)
        {
            s_logger.error ("更新摆药记录表时，对象不能为空");
            throw new IllegalArgumentException ("更新摆药记录表时，条件对象不能为空");
        }
        try
        {
            return m_inpPhamDispenseDetailManager.modifyInpPhamDispenseDetail (inpPhamDispenseDetail);
        }
        catch (Exception e)
        {
            s_logger.error ("更新摆药记录表异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("更新摆药记录表异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public int modifyInpPhamDispenseDetailByExample (InpPhamDispenseDetail inpPhamDispenseDetail)
    {
        s_logger.info ("调用modifyInpPhamDispenseDetailByExample参数 ：inpPhamDispenseDetail:{}", new Object[]
        { inpPhamDispenseDetail });
        if (inpPhamDispenseDetail == null)
        {
            s_logger.error ("更新摆药记录表时，对象不能为空");
            throw new IllegalArgumentException ("更新摆药记录表时，条件对象不能为空");
        }
        try
        {
            return m_inpPhamDispenseDetailManager.modifyInpPhamDispenseDetailByExample (inpPhamDispenseDetail);
        }
        catch (Exception e)
        {
            s_logger.error ("更新摆药记录表异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("更新摆药记录表异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public void addInpPhamDispenseDetail (InpPhamDispenseDetail inpPhamDispenseDetail)
    {
        s_logger.info ("调用addInpPhamDispenseDetail参数 ：inpPhamDispenseDetail:{}", new Object[]
        { inpPhamDispenseDetail });
        if (inpPhamDispenseDetail == null)
        {
            s_logger.error ("添加摆药记录时，对象不能为空");
            throw new IllegalArgumentException ("添加摆药记录时，条件对象不能为空");
        }
        try
        {
            m_inpPhamDispenseDetailManager.addInpPhamDispenseDetail (inpPhamDispenseDetail);
        }
        catch (Exception e)
        {
            s_logger.error ("添加摆药记录异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("添加摆药记录异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public int removeInpPhamDispenseDetailByID (Long id)
    {
        s_logger.info ("调用removeInpPhamDispenseDetailByID参数 ：id:{}", new Object[]
        { id });
        if (id == null)
        {
            s_logger.error ("通过主键删除摆药记录时，主键不能为空");
            throw new IllegalArgumentException ("添加摆药记录时，条件对象不能为空");
        }
        try
        {
            return m_inpPhamDispenseDetailManager.removeInpPhamDispenseDetailByID (id);
        }
        catch (Exception e)
        {
            s_logger.error ("通过主键删除摆药记录异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过主键删除摆药记录异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public void addInpPhamDispenseDetailList (List <InpPhamDispenseDetail> list)
    {
        s_logger.info ("调用addInpPhamDispenseDetailList参数 ：list:{}", new Object[]
        { list });
        if (list == null)
        {
            s_logger.error ("批量添加摆药执行明细时，保存对象不能为空");
            throw new IllegalArgumentException ("批量添加摆药执行明细时，保存对象不能为空");
        }
        try
        {
            m_inpPhamDispenseDetailManager.addInpPhamDispenseDetailList (list);
        }
        catch (Exception e)
        {
            s_logger.error ("批量添加摆药执行明细异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("批量添加摆药执行明细异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public List <InpPhamDispenseDetail> findDispenseDetailListByApplyDetailIdList (List <Long> list)
    {
        s_logger.info ("调用findDispenseDetailListByApplyDetailIdList参数 ：list:{}", new Object[]
        { list });
        if (list == null)
        {
            s_logger.error ("通过请领明细主键查询摆药执行明细时，请领明细主键列表不能为空");
            throw new IllegalArgumentException ("通过请领明细主键查询摆药执行明细时，请领明细主键列表不能为空");
        }
        try
        {
            return m_inpPhamDispenseDetailManager.findDispenseDetailListByApplyDetailIdList (list);
        }
        catch (Exception e)
        {
            s_logger.error ("通过请领明细主键查询摆药执行明细异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过请领明细主键查询摆药执行明细异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public int modifyInpPhamDispenseDetailList (List <InpPhamDispenseDetail> list)
    {
        s_logger.info ("调用modifyInpPhamDispenseDetailList参数 ：list:{}", new Object[]
        { list });
        if (list == null)
        {
            s_logger.error ("通过主键ID批量更新摆药执行明细时，更新对象不能为空");
            throw new IllegalArgumentException ("通过主键ID批量更新摆药执行明细时，更新对象不能为空");
        }
        try
        {
            return m_inpPhamDispenseDetailManager.modifyInpPhamDispenseDetailList (list);
        }
        catch (Exception e)
        {
            s_logger.error ("通过主键ID批量更新摆药执行明细异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过主键ID批量更新摆药执行明细异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public List <InpPhamDispenseDetail> findInpPhamDispenseDetailListByCondition (InpPhamDispenseDetail inpPhamDispenseDetail)
    {
        s_logger.info ("调用findInpPhamDispenseDetailListByCondition参数 ：inpPhamDispenseDetail:{}", new Object[]
                { inpPhamDispenseDetail });
                if (inpPhamDispenseDetail == null)
                {
                    s_logger.error ("通过条件查询摆药记录表时，条件对象不能为空");
                    throw new IllegalArgumentException ("通过条件查询摆药记录表时，条件对象不能为空");
                }
                try
                {
                    List <InpPhamDispenseDetail> list = m_inpPhamDispenseDetailManager.findInpPhamDispenseDetailListByCondition (inpPhamDispenseDetail);
                    list = m_translatorManager.translate (list);
                    return list;
                }
                catch (Exception e)
                {
                    s_logger.error ("通过条件查询摆药记录表异常" + e.getLocalizedMessage (), e);
                    throw new BusinessException ("通过条件查询摆药记录表异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
                }
         
    }
 
    /** 公司版权信息. */
    public static final String copyright = "Copyright 2014, XuNuo Corporation";

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";

    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";

    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";

    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";

    @Override
    public List <InpPhamDispenseDetail> findInpPhamDispenseDetail (InpPhamDispenseDetail inpPhamDispenseDetail)
    {
         s_logger.debug("进入findInpPhamDispenseDetail方法,入参:");
        
        return m_inpPhamDispenseDetailManager.findInpPhamDispenseDetail (inpPhamDispenseDetail);
         
    }

  
}
